﻿using System;

using OCXS;
using OCXS.OCXSServiceLibrary.OPCXMLDA10;

namespace OCXS {

	namespace OCXSServiceLibrary {
        
		public partial class OCXSService {
            
			/// <summary>
            ///     <para>
            ///         Implements OPC XML DA 1.0 GetStatus service. 
            ///     </para>
            /// 
            ///     <para>
            ///         See OPC XML DA 1.0 specification for more information about GetStatus service.
            ///     </para>
            /// </summary>
            /// 
            /// <remarks>
            ///     <para>
            ///         <b>Following there's a list of implemented (or not) standard features.</b>
            ///     </para>
            /// 
            ///     <para>
            ///         The following <c>GetStatusRequest</c> standard features are (or not) implemented.
            /// 
            ///         <ul>
            ///             <li><b>ClientRequestHandle: </b> supported.</li>
            ///             <li><b>LocaleID: </b> supported.</li>
            ///         </ul>
            ///     </para>
            ///     
            /// <para>
            ///     The following <c>GetStatusResponse</c> standard features are (or not) implemented.
            ///     <ul>
            ///         
            ///         <li>
            ///             <b>GetStatusResult: </b> the following features are (or not) supported:
            ///             <ul>
            ///                 <li><b>ClientRequestHandle: </b> supported.</li>
            ///                 <li><b>RcvTime: </b> supported (evaluated as first instruction).</li>
            ///                 <li><b>ReplyTime: </b> supported (evaluated as last instruction).</li>
            ///                 <li><b>RevisedLocaleID: </b> supported (<c>en-us</c>).</li>
            ///                 <li><b>ServerState: </b> supported (<c>running</c>).</li>
            ///             </ul>
            ///         </li>
            ///         
            ///         <li>
            ///             <b>Status: </b> the following features are (or not) supported:
            ///             <ul>
            ///                 <li><b>ProductVersion: </b> supported.</li>
            ///                 <li><b>StartTime: </b> not supported (static value returned).</li>
            ///                 <li><b>StatusInfo: </b> supported (no additional status information provided).</li>
            ///                 <li><b>SupportedInterfaceVersions: </b> supported.</li>
            ///                 <li><b>SupportedLocaleIDs: </b> supported (<c>en-us</c>).</li>
            ///                 <li><b>VendorInfo: </b> supported.</li>
            ///             </ul>
            ///         </li>
            ///         
            ///     </ul>
            /// </para>
            /// 
            /// <code>
            /// // The following code can be found in OCXSClient and 
            /// // shows how to call GetStatus service.
            /// class Program {
            ///
            ///     private const string EndpointAddress = "http://localhost/OCXS/OCXS.svc";
            ///     
            ///     static void Main(string[] args) {
            ///     
            ///     GetStatus("en-us", "0x00FF");
            /// }
            ///     
            /// public static GetStatusResponse GetStatus(string localeID, string clientRequestHandle) {
            ///	    // Get the channel
            ///	    // GetOCXSChannel can be found in OCXSClient.
            ///	    IOCXSService svc = GetOCXSChannel(EndpointAddress);
            /// 
            /// 	// Create the request.
            /// 	GetStatusRequest GSR = new GetStatusRequest(localeID, clientRequestHandle);
            /// 
            /// 	// Perform the call to service and get the response.
            /// 	GetStatusResponse res = svc.GetStatus(GSR);
            /// 
            ///     // Print the response.
            ///     // PrintResponse can be found in OCXSClient.
            /// 	PrintResponse(res);
            /// 
            /// 	return res;
            /// }
            /// </code>
            /// 
            /// </remarks>
            /// <param name="request">The <c>GetStatusRequest</c> issued by client according to OCP XML DA 1.0 specification.</param>
            /// <returns>A <c>GetStatusResponse</c> according to OPC XML DA 1.0 specification.</returns>
			public GetStatusResponse GetStatus(GetStatusRequest request) {

                ReplyBase RB = this.GetReplyBase(request.ClientRequestHandle, request.LocaleID); /* Get RB */

                ServerStatus SS = new ServerStatus();
                SS.VendorInfo = "OCXS";
                SS.SupportedInterfaceVersions = new interfaceVersion[] { interfaceVersion.XML_DA_Version_1_0 };
                SS.StartTime = new DateTime(2001, 9, 11);
                SS.ProductVersion = "1.0.0";
                SS.SupportedLocaleIDs = new string[] { "en-us" };
                SS.StatusInfo = "";

                GetStatusResponse GSR = new GetStatusResponse(RB, SS);

                RB.ReplyTime = DateTime.Now;

                return GSR;

			}
            
		}
        
	}

}
